package edu.wpi.cs509.ui.menu;

import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;

import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.KeyStroke;

import edu.wpi.cs509.ui.A__MainStrategoClient;

/**
 * The StrategoMenu implements the Stratego client main frame menu.
 * 
 * @author afoltan
 *
 */
@SuppressWarnings("serial")
public class StrategoMenu extends JMenuBar {
	
	// The instance of the stratego client
	A__MainStrategoClient client;
	
	/**
	 * Contructor for the stratego menu
	 * @param A__MainStrategoClient
	 */
	public StrategoMenu( A__MainStrategoClient client ) {
		super();
		this.client = client;
		initialize();
	}
	
	/**
	 * Initialize constructs the menu hierarchy and instantiates the action listeners
	 * for each menu item.  At the end, the menu is made visible.
	 */
	private void initialize() {
		
		JMenuItem menuItem;
	
		// Stratego Menu
		JMenu strategoMenu = new JMenu("Stratego");
		strategoMenu.setMnemonic(KeyEvent.VK_S);
		strategoMenu.getAccessibleContext().setAccessibleDescription("Stratego Menu");
		add(strategoMenu);

		menuItem = new JMenuItem("Quit", KeyEvent.VK_Q);
		menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.ALT_MASK));
		menuItem.getAccessibleContext().setAccessibleDescription("Quit");
		
		strategoMenu.add(menuItem);
		
		menuItem.addActionListener( new MenuActionQuit( client ) );
		
		setVisible(true);
	}
	
	public void addGameMenus() {
		JMenuItem menuItemLB;
		JMenuItem menuItemPS;
		JMenuItem menuItemHR;
		JMenuItem menuItemHA;
		
		JMenu viewMenus = new JMenu("View");
		JMenu helpMenus = new JMenu("Help");
		add(viewMenus);
		add(helpMenus);
		
		menuItemLB = new JMenuItem("Leader Board", KeyEvent.VK_L);
		menuItemLB.getAccessibleContext().setAccessibleDescription("View Leader Board");
		menuItemLB.addActionListener( new MenuActionViewLeaderBoard( client ));
		
		viewMenus.add(menuItemLB);
	
		menuItemPS = new JMenuItem("Personal Stats", KeyEvent.VK_L);
		menuItemPS.getAccessibleContext().setAccessibleDescription("View Personal Stats");
		menuItemPS.addActionListener( new MenuActionViewPersonalStats( client ));
		
		viewMenus.add(menuItemPS);
		
		menuItemHR = new JMenuItem("Help Rules", KeyEvent.VK_L);
		menuItemHR.getAccessibleContext().setAccessibleDescription("Help Rules");
		menuItemHR.addActionListener( new MenuActionHelpRules(client));
		
		helpMenus.add(menuItemHR);
		
		menuItemHA = new JMenuItem("Help About", KeyEvent.VK_L);
		menuItemHA.getAccessibleContext().setAccessibleDescription("Help About");
		menuItemHA.addActionListener( new MenuActionAbout(client));
		
		helpMenus.add(menuItemHA);
		
		setVisible(true);
		
	}
}
